package model

import "github.com/fakeyanss/jt808-server-go/internal/codec/hex"

type Msg9101Param struct {
	IPAddrLen  uint8  `json:"ipAddrLen"`
	IPAddr     string `json:"ipAddr"`
	PortTCP    uint16 `json:"portTCP"`
	PortUDP    uint16 `json:"portUDP"`
	ChannelNo  uint8  `json:"channelNo"`
	DataType   uint8  `json:"dataType"`
	StreamType uint8  `json:"streamType"`
}

// Msg9101 实时音视频传输请求
type Msg9101 struct {
	Header *MsgHeader `json:"header"`
	Msg9101Param
}

func (m *Msg9101) Decode(packet *PacketData) error {
	return nil
}

func (m *Msg9101) Encode() (pkt []byte, err error) {
	pkt = hex.WriteByte(pkt, m.IPAddrLen)
	pkt = hex.WriteString(pkt, m.IPAddr)
	pkt = hex.WriteWord(pkt, m.PortTCP)
	pkt = hex.WriteWord(pkt, m.PortUDP)
	pkt = hex.WriteByte(pkt, m.ChannelNo)
	pkt = hex.WriteByte(pkt, m.DataType)
	pkt = hex.WriteByte(pkt, m.StreamType)

	pkt, err = writeHeader(m, pkt)
	return pkt, err
}

func (m *Msg9101) GetHeader() *MsgHeader {
	return m.Header
}

func (m *Msg9101) GenOutgoing(incoming JT808Msg) error {
	return nil
}
